package com.cr.admin.system.controller;

import com.cr.admin.system.pojo.dto.SysOperateLogQuery;
import com.cr.admin.system.pojo.entity.SysOperateLog;
import com.cr.admin.system.service.ISysOperateLogService;
import com.cr.common.response.PageData;
import com.cr.common.response.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "75.操作日志管理")
@RestController
@RequestMapping("/api/sys/operateLogs")
public class SysOperateLogController {

    @Autowired
    private ISysOperateLogService sysOperateLogService;

    @ApiOperation(value = "查询操作日志详情")
    @ApiOperationSupport(order = 400)
    @GetMapping("/{id}")
    public JsonResult getDetail(@PathVariable("id") Long id) {
        SysOperateLog sysOperateLog = sysOperateLogService.selectById(id);
        return JsonResult.success(sysOperateLog);
    }

    @ApiOperation(value = "查询操作日志列表")
    @ApiOperationSupport(order = 410)
    @GetMapping
    public JsonResult list(Integer pageNum, Integer pageSize, SysOperateLogQuery query) {
        PageData<SysOperateLog> pageData =
                PageData.page(pageNum, pageSize, () -> sysOperateLogService.selectList(query));
        return JsonResult.success(pageData);
    }

}
